﻿@model ToWaTimeReportMVC4.Models.ProjectWrapper
@{
    ToWaTimeReportMVC4.Models.ToWaService service = new ToWaTimeReportMVC4.Models.ToWaService();
    ToWaTimeReportMVC4.Models.User user = service.GetUserByUsername(User.Identity.Name);
    List<ToWaTimeReportMVC4.Models.ConsultantWrapper> ConsultantWeek = service.GetConsultantsWorkedHoursByProjectId(Model.Id, DateTime.Now.AddDays(-7), DateTime.Now);
    List<ToWaTimeReportMVC4.Models.ConsultantWrapper> ConsultantMonth = service.GetConsultantsWorkedHoursByProjectId(Model.Id, DateTime.Now.AddDays(-31), DateTime.Now);

    if (user != null)
    {
        if (user.Type == 0 || user.Type == 1)
        {
@section featured {
    <section class="featured">
    <div class="content-wrapper">
        <hgroup class="title">
            <h1>Customer Profile</h1>
        </hgroup>
    </div>
</section>
}

<table>
    <tr>
        <th>@Html.Label(Model.Name)</th>
    </tr>
    <tr>
        <td>@Html.Label(Model.Description)</td>
        <td>Owner: @Html.Label(service.GetUserById(Model.UserId).Username)</td>
    </tr>
    <tr>
        <td>Cost: @service.GetProjectCost(Model.Id)</td>
    </tr>
</table>
    
<table>
    <tr>
        <th>Weekly</th>
    </tr>
    <tr>
        <td>@Html.Label(Model.Description)</td>
        <td>Owner: @Html.Label(service.GetUserById(Model.UserId).Username)</td>
    </tr>
    @{
            foreach (ToWaTimeReportMVC4.Models.ConsultantWrapper cw in ConsultantWeek)
            {
            <tr>
                <td>@cw.Consultant.Username</td>
                <td>@cw.TimeSpent</td>
            </tr>   
            }
    }
    <tr>
        <td>Cost: @service.GetProjectCostBetweenDates(Model.Id, DateTime.Now.AddDays(-7), DateTime.Now)</td>
    </tr>
</table>
    
<table>
    <tr>
        <th>Monthly</th>
    </tr>
    <tr>
        <td>@Html.Label(Model.Description)</td>
        <td>Owner: @Html.Label(service.GetUserById(Model.UserId).Username)</td>
    </tr>
    @{
            foreach (ToWaTimeReportMVC4.Models.ConsultantWrapper cw in ConsultantMonth)
            {
            <tr>
                <td>@cw.Consultant.Username</td>
                <td>@cw.TimeSpent</td>
            </tr>   
            }
    }
    <tr>
        <td>Cost: @service.GetProjectCostBetweenDates(Model.Id, DateTime.Now.AddDays(-31), DateTime.Now)</td>
    </tr>
</table>
        }
        else
        {
            <p>Permission denied!</p>
        }
    }
}